﻿//========================================================= 
/**@file ComMifare1Card_TestContainer.h
 * @brief 
 * 
 * @date 2016-08-13   15:29:54
 * @author Zhyioo 
 * @version 1.0
 */ 
//--------------------------------------------------------- 
#ifndef _LIBZHOUYB_COMMIFARE1CARD_TESTCONTAINER_H_
#define _LIBZHOUYB_COMMIFARE1CARD_TESTCONTAINER_H_
//--------------------------------------------------------- 
#include "ComICC_TestContainer.h"
//--------------------------------------------------------- 
namespace zhou_yb {
namespace application {
namespace test {
//--------------------------------------------------------- 
/**
 * @brief 接触式存储卡接口适配器
 * @date 20160813 14:42
 *
 * @param TContainer 需要适配的底层容器
 * @param TMifare1CardAdapter M1卡适配器类型
 */
template<class TContainer, class TMifare1CardAdapter>
class ComMifare1Card_TestContainer : public ITestContainer<typename TContainer::DeviceType, IMifare1Card>
{
protected:
    TContainer _testContainer;
    TMifare1CardAdapter _mifare1Card;
public:
    virtual Ref<IMifare1Card> Adapter(const Ref<typename TContainer::DeviceType>& dev, IMifare1Card*, TextPrinter& printer)
    {
        typename TContainer::TransInterfaceType* pInterface = NULL;
        Ref<typename TContainer::TransInterfaceType> ref = _testContainer.Adapter(dev, pInterface, printer);
        _mifare1Card.SelectDevice(ref);
        if(_mifare1Card.ActiveStorageCard(0x00))
            return _mifare1Card;
        return Ref<IMifare1Card>();
    }
};
//--------------------------------------------------------- 
} // namespace test 
} // namespace application 
} // namespace zhou_yb 
//--------------------------------------------------------- 
#endif // _LIBZHOUYB_COMMIFARE1CARD_TESTCONTAINER_H_
//========================================================= 